
const express = require('express')
const app = express()

// 全局中间件
app.use((req, res, next) => {
    console.log('我是中间件1');
    next()
})
app.use((req, res, next) => {
    console.log('我是中间件2');
    next()
})
const mw3 = (req, res, next) => {
    console.log('我是中间件3');
    next()
}
app.get('/', (req, res) => {
    res.send({ name: 'Lishumin' })
})
// 局部中间价
app.get('/abc', mw3, (req, res) => {
    res.send({ name: 'abc' })
})
// 托管静态文件
app.use(express.static('./files'))

// 挂载路径前缀
app.use('/files', express.static('./files'))

app.listen(5000, () => {
    console.log('服务器已启动。。http://127.0.0.1:5000');
})